﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MailInputModels>" %>

<%@ Import Namespace="SDT.Systems" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Sửa email
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("edit", "mail", FormMethod.Post, new
       {
           id = "adminForm",
           enctype = "multipart/form-data"
       }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <% string strCheckBox = "<input type='checkbox' name='{0}' id='{1}' value='{2}' {3} />";
       string checkboxChecked = string.Empty;
           %>
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">
                    Tiêu đề (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBoxFor(m=>m.Mail.Subject, new { style = "width: 700px;", @class = "required" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Nội dung mail (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextAreaFor(m=>m.Mail.Message, new { style = "width: 700px; height:400px" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Chọn chuyên mục liên kết
                </td>
                <td>
                    <div style="height: 200px; overflow-y: scroll; margin-bottom: 12px; border-bottom: 1px solid #cccccc; margin-top: 10px; width:700px">
                        <table>
                            <% if (Model.Categories != null && Model.Categories.Count() > 0)
                               {
                                   foreach (var a in Model.Categories)
                                   {
                                       if (Model.Mail.MailCategoryMaps.Where(e => e.CatID==a.ID).ToList().Count>0)
                                           checkboxChecked = "checked='checked'";
                                   %>
                            <tr>
                                <td><%= string.Format(strCheckBox, "CatID", "CatID", a.ID, checkboxChecked) %></td>
                                <td><%= a.Name %></td>
                            </tr>
                            <% checkboxChecked = string.Empty;
                                   }
                               } %>
                        </table>                    
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                     <%= Html.Hidden("hdStatus") %>
                    <input type="submit" id="btnSave" value="Lưu lại" onclick="return CheckSendMail(0);" />
                    <input type="submit" id="btnSaveAndSend" value="Lưu & Gửi mail" onclick="return CheckSendMail(1);" />
                </td>
            </tr>
        </tbody>
    </table>
    <%}
      } %>
        <script type="text/javascript">
          function CheckSendMail(isSend) {
              if (isSend > 0) {
                  ChangeStatusObject('hdStatus', 1);
                  issubmit = true;
                  return issubmit;
              } else {
                  ChangeStatusObject('hdStatus', 0);
              }
              return true;
          }
          tinyMCE.init({
              mode: "textareas",
              theme: "advanced",
              plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
              theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
              theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
              theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
              theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
              theme_advanced_toolbar_location: "top",
              theme_advanced_toolbar_align: "left",
              theme_advanced_statusbar_location: "bottom",
              paste_use_dialog: false,
              paste_auto_cleanup_on_paste: true,
              paste_convert_headers_to_strong: false,
              paste_strip_class_attributes: "all",
              paste_remove_spans: true,
              paste_remove_styles: true
          });          
      </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Quay lại", "/mail", "back")%>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Sửa email
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
